package JavaSE.d6;
/*
创建20个线程，设置不同的线程优先级，体会优先级高的线程优先运行
 */
public class Test8 {
    public static void main(String[] args) {
        soud soud = new soud();
        Thread thread1 = new Thread(soud);
        Thread thread2 = new Thread(soud);
        Thread thread3 = new Thread(soud);
        Thread thread4 = new Thread(soud);
        Thread thread5 = new Thread(soud);
        thread1.setName("one");
        thread2.setName("two");
        thread3.setName("there");
        thread4.setName("four");
        thread5.setName("five");
        thread1.setPriority(1);
        thread2.setPriority(3);
        thread3.setPriority(5);
        thread4.setPriority(7);
        thread5.setPriority(9);
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
    }
}
class soud implements Runnable{
    @Override
    public void run() {
        for (int i = 0; ; i++) {
            System.out.println(Thread.currentThread().getName()+"执行");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}